home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tricks of the Mac Game Programming Gurus
/
TricksOfTheMacGameProgrammingGurus.iso
/
More Source
/
Libraries
/
SAT 2.3b4
/
Demo ƒ
/
Zkrolly demo ƒ
/
Zkrolly.c
< prev
next >
Wrap
Text File
|
1995-01-17
|
3KB
|
110 lines
//• C translation from Pascal source file: Zkrolly.p
//• main Zkrolly;
#include "SAT.h"
extern void InitXprite(void);
extern pascal void SetupXprite(SpritePtr me);
extern pascal void HandleXprite(SpritePtr me);
extern void InitZprite(void);
extern pascal void SetupZprite(SpritePtr me);
extern pascal void HandleZprite(SpritePtr me);
SpritePtr ignoresp, zp;
WindowPtr Zwind;
Rect r;
enum {
scrollSizeH = 200,
scrollSizeV = 150
};
Boolean IsOptionPressed()
{
KeyMap km;
// GetKeys(&km);
GetKeys(km);
return (km[1] & 4)!=0;
}
pascal Boolean Zyncho()
{
Rect where, dest;
where.top = zp->position.v;
where.left = zp->position.h;
where.left = where.left - (scrollSizeH >> 1);
where.top = where.top - (scrollSizeV >> 1);
if (where.left < 0)
where.left = 0;
if (where.top < 0)
where.top = 0;
if (where.left + scrollSizeH > gSAT.offSizeH)
where.left = gSAT.offSizeH - scrollSizeH;
if (where.top + scrollSizeV > gSAT.offSizeV)
where.top = gSAT.offSizeV - scrollSizeV;
where.bottom = where.top + scrollSizeV;
where.right = where.left + scrollSizeH;
SetRect(&dest, 0, 0, scrollSizeH, scrollSizeV);
SATSetPortScreen();
CopyBits(&gSAT.offScreen.port->portBits, &gSAT.wind.port->portBits, &where, &dest, srcCopy, nil);
/* SATCopyBits is obsolete. For large areas, it is hardly any better
than CopyBits anyway. */
/* SATCopyBitsToScreen(gSAT.offScreen, where, dest, IsOptionPressed());*/
/* Note that there's hardly any speed difference between fast and safe mode when copying areas this big!*/
return true; //• Tell SAT not to draw on-screen: we do that ourselves!.
}
void SetupZwind()
{
Rect zr;
SysEnvRec wrld;
//• Since SAT hasn't been initialized, we can't use gSAT.colorFlag but
//• have to check environs ourselves.
if ( noErr != SysEnvirons(1, &wrld))
;//• ignore errors.
SetRect(&zr, 20, 30, 20 + scrollSizeH, 30 + scrollSizeV);
if ( wrld.hasColorQD )
Zwind = NewCWindow(0L, &zr, "\p", false, plainDBox, (WindowPtr)-1L, false, 0);
else
Zwind = NewWindow(0L, &zr, "\p", false, plainDBox, (WindowPtr)-1L, false, 0);
}
main ()
{
SATInitToolbox();
SetupZwind ();
SetRect(&r, 0, 0, 510, 340);
SATCustomInit(128, 129, &r, Zwind, 0L, false, false, false, true, false);
InitXprite ();
InitZprite ();
ShowWindow(gSAT.wind.port);
SelectWindow(gSAT.wind.port);
SATInstallSynch(&Zyncho);
zp = SATNewSprite(0, 90, 70, &SetupZprite);
ignoresp = SATNewSprite(0, 120, 100, &SetupXprite);
ignoresp = SATNewSprite(0, 200, 160, &SetupXprite);
SATSetPortScreen();
do
{
SATRun(IsOptionPressed());
} while (! Button ());
//• WARNING! It seems like we mess up the current device somewhere.
//• Probably a bug in SAT (where the device setting isn't perfect
//• yet). Let's set port and device to something nice and safe!.
SATSetPortScreen();
/* Finally, make sure we dispose of the sound channel. */
SATSoundShutup();
}